﻿using System;
using System.Collections.Generic;
using Sustainalytics.BusinessResearchProductStates.Entities.ResearchState;
using Sustainalytics.ClientDW.Entities;
using Sustainalytics.MongoDB.Extensions;
using Xunit;
using Sustainalytics.CRT.Synchronization;
using Sustainalytics.ESG.Entities;

namespace Sustainalytics.CRT.Synchronization.Tests
{

    public class MarketCapitalizationHelperTests
    {
        private readonly string cnx =
            "mongodb://54.72.160.155:27017/ClientDW_B";

        private readonly MarketCapitalizationProcessor sut;

        public MarketCapitalizationHelperTests()
        {

            var resultCollection = MongoFactory.GetCollectionFromDatabase<RPCompanyESGComputationResult>(cnx);
            var corporateDataCollection = MongoFactory.GetCollectionFromDatabase<CorporateData>(cnx);
            var financialDataCollection = MongoFactory.GetCollectionFromDatabase<FinancialData>(cnx);
         
            sut = new MarketCapitalizationProcessor(corporateDataCollection, resultCollection, financialDataCollection);
        }

        [Fact]
        public void Compute_MarketCap_ForOneCompany_In_Homebuilder_peergroup()
        {

            var companyMock = new RPCompanyESGComputationResult
            {

                Id =
                                          new Guid("50a74d00-e17e-47bf-aa14-039cb3c38984"),
                UniverseIds = new List<int>(1),
                IsInReferenceUniverse = true
            };

            sut.AppendPeersListToResult(companyMock, "Homebuilders");

            Assert.Equal(companyMock.RelativePosition.PeersList.Length, 5);
        }
    }
}